import {getOffsetCoor, getClientCoor, clone} from 'common/func'

export const moveMixin = {
    data() {
        return {
            moving: false,
            moveData: {
                startX: '',
                startY: ''
            }
        }
    },
	methods: {
		mousedown(event) {
            this.moving = true
            this.moveData = getOffsetCoor(event)
        },
        mousemove(event, type) {
            if(this.moving){
                let nowData = getClientCoor(event)
                if(type == 'chatBox'){
                    if(this.showChatLog){
                        return false;
                    }
                    if(this.chatBoxFull){
                        this.__changeChatBoxType('chatBox');
                    }
                    this.chatBoxConfig.marginTop = "0";
                    this.chatBoxConfig.marginLeft = "0";
                    this.chatBoxConfig.top = (nowData.endY - this.moveData.startY) + 'px';
                    this.chatBoxConfig.left = (nowData.endX - this.moveData.startX) + 'px';
                } else if(type == 'chatOpen') {
                    // if(this.showChatLog){
                    //     return false;
                    // }
                    this.chatOpenConfig.top = (nowData.endY - this.moveData.startY) + 'px';
                    this.chatOpenConfig.left = (nowData.endX - this.moveData.startX) + 'px';
                } else if(type == 'chatLog') {
                    if(this.chatLogFull){
                        this.__changeChatLogType('chatLog');
                    }
                    this.chatLogConfig.left = (nowData.endX - this.moveData.startX) + 'px';
                }
            }
        },
        mouseup() {
            this.moving = false;
        }
	}
}